package org.hk.kg.finance.coststander.action;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.hk.kg.TraceObject;
import org.hk.kg.db.DBServiceProxy;
import org.hk.kg.finance.FinanceConstants;
import org.hk.kg.finance.costype.service.CostypeService;
import org.hk.kg.finance.costype.service.ICostypeService;
import org.hk.kg.ui.ParamsStack;
import org.hk.kg.utils.Constants;
import org.hk.kg.web.BaseAction;

public class CostStanderAction extends BaseAction {
	private ICostypeService costTypeService = DBServiceProxy.getProxyClz(CostypeService.class);
	
	public TraceObject doQuery(ParamsStack params)
	{
		TraceObject trace = new TraceObject("cost_stander_queried", true);
		trace.setParams(params.getSimpleParams());
		return trace;
	}
	
	public String getClassTypes()
	{
		Map<String, String> clzTypes = Constants.CONFIG.getGroup(FinanceConstants.CLZ_TYPE_CONSTANTS);
		StringBuffer buffer = new StringBuffer();
		for(Entry<String, String> entry : clzTypes.entrySet())
		{
			buffer.append("<option value=\"").append(entry.getKey()).append("\">")
			.append(entry.getValue()).append("</option>\n");
		}
		return buffer.toString();
	}
	
	public String getCostTypes()
	{
		List<Map> costypes = costTypeService.queryCostTypes();
		StringBuffer buffer = new StringBuffer();
		for(Map costype : costypes)
		{
			buffer.append("<option value=\"").append(costype.get("costTypeId")).append("\">")
			.append(costype.get("costTypeName")).append("</option>\n");
		}
		return buffer.toString();
	}
}
